package com.xujie.chat.client.handler;

import com.xujie.chat.message.MyMessage;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * @author Xujie
 * @since 2024/12/28 22:25
 **/


public class MessageHandler extends SimpleChannelInboundHandler<MyMessage> {
    private static final Logger LOG = LoggerFactory.getLogger(MessageHandler.class);
    private final String msgTemplate = "客户端: 发送消息：%s";

    @Override
    protected void channelRead0(ChannelHandlerContext ctx, MyMessage msg) throws Exception {
        System.out.println(String.format(msgTemplate, msg.getBody()));
    }
}
